pkcs1v15: retrofit deterministic implicit rejection for decryption#685
pkcs1v15: retrofit deterministic implicit rejection for decryption#685EffortlessSteven wants to merge 6 commits intoRustCrypto:masterfrom
Conversation
8e622fd to
4a7234a
Compare
|
Claude code generated code. There are issues with the lack of use of types (use of Vec instead of an Arrays as used throughout rustcrypto). Honestly this is a time waster, I'd rather we close this. |
|
On Cargo.toml The new decrypt path uses
On Vec vs arrays The public The fixed 256-byte candidate-length block could tighten to
Reviewer map Most of the 16 files are fixtures, tests, or docs. The real production change is four files. Review order:
Happy to narrow further if specific areas are still noisy. |
68f11f4 to
84888dd
Compare
PKCS#1 v1.5 decrypt currently leaks padding validity through
Error::Decryption. This PR removes that distinguisher without changing the public decrypt API.It keeps the existing trait surface and
Result<Vec<u8>>, standardizes the outer public-invalid boundary so wrong-length ciphertexts and out-of-range ciphertext representatives still returnErr(Error::Decryption), and changes only padding-invalid but otherwise public-valid ciphertexts to return the deterministic rejection symbol.What changes
src/algorithms/pad.rs,src/algorithms/pkcs1v15.rs, andsrc/pkcs1v15.rssha2feature name for compatibility. SHA-256 is now an unconditional internal dependency for PKCS#1 v1.5 implicit rejection, while thesha2feature continues to gate the SHA-2 reexport and PKCS#1 v1.5 signature OID implsWhat does not change
sha2feature rename or removalDH = SHA256(D)caching optimizationEvidence
c >= nciphertexts still returnErr(Error::Decryption); identical invalid ciphertexts remain deterministic; distinct invalid ciphertexts produce distinct rejection symbols; valid ciphertexts still decrypt normally;RsaPrivateKey::decrypt(...)andpkcs1v15::DecryptingKeyagree on the shared pathcargo test --test pkcs1v15_implicit_rejection --all-features;cargo test --lib --tests --all-features;cargo check --all-features;cargo check --no-default-featuresvalid_0vszero_byte_in_padding_48_4suspicion. Current conclusion: supportive evidence, not closure.Follow-up work
Phase-two follow-ups should stay separate from this retrofit: